﻿#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

typedef double Real;
typedef long long MyInt;


typedef struct TContext_s
{
	int a;
	int n;
}TContext;

TContext context;

void read_data(TContext* ctx)
{
	scanf("%d", &ctx->n);
}

int prime(int p)
{
	if (p < 2)
		return 0;
	else if (p < 4)
		return 1;
	else if (p % 2 == 0)
		return 0;
	int p2 = (int)sqrt(p) + 1;
	for (int i = 3; i <= p2; i += 2)
		if (p % i == 0)
			return 0;
	return 1;
}

int mn[10] = { 0 };
int sxh(int k)
{
	int k0 = k;
	int s = 0;
	while (k)
	{
		s += mn[k % 10];
		k /= 10;
	}
	if (s == k0)
		return 1;
	return 0;
}


void do_task(TContext* ctx)
{
	for (int i = 1; i < 10; ++i)
		mn[i] = pow(i, ctx->n);
	int first = pow(10, ctx->n-1);
	int last = first * 10 - 1;
	for (int i = first; i < last; ++i)
		if (sxh(i))
			printf("%d\n", i);
}

void solve(TContext* ctx)
{
	read_data(ctx);
	do_task(ctx);
}

int main()
{
	freopen("D:/Develop/GitRepos/MOOC/浙江大学/数据结构/201906/DataStructure/M2019秋C入门和进阶练习集/7-145.txt", "r", stdin);
	solve(&context);
	return 0;
}
